#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: ystlong
# @Date:   2018-07-01 00:19:47
# @Last Modified by:   ystlong
# @Last Modified time: 2018-07-01 12:22:17

import sys

def gen_key(keys):
	key_len = len(keys)
	for i in xrange(key_len-1):
		key1 = keys[i]
		key2 = keys[i+1]
		l1 = len(key1)
		l2 = len(key2)
		gen_key = []
		for j in xrange(min(l1, l2)):
			if key1[j] == key2[j]:
				gen_key.append(key1[j])
			else:
				gen_key.append(".")
		keys[i+1] = "".join(gen_key)
	print keys[-1]

def read_keys(filename):
	keys = []
	with open(filename) as f:
		for line in f:
			line = line.strip()
			if line != "":
				keys.append(line)
	return keys

def main():
	key_file = None
	keys = None
	if(len(sys.argv) == 2):
		keys = read_keys(sys.argv[1])
	elif(len(sys.argv) < 3):
		print "usage: %s [key_file] [key1 key2 ... keyn]"%(sys.argv[0])
		sys.exit(1)
	else:
		keys = sys.argv[1:]
	if not keys or len(keys) < 2:
		print "keys len error must uper 2"
		sys.exit(2)
	gen_key(keys)


if __name__ == '__main__':
	main()

